import Vue from 'vue'
import VueRouter from 'vue-router'
import Router from 'vue'
import mainRouter from '@/views/main/routes'
import loginRouter from '@/views/login/route'

import MineRouter from '@/views/mines/route'
import MovieRouter from '@/views/movies/route'
Vue.use(VueRouter)

const routes = [
  {
    path: '', 
    redirect:"/guide"
  },
  {
    path: '/guide',
    name: 'guide',
    component: () => import('@/views/guide/guide.vue')
  },
  {
    path: '/app',
    name: 'app',
    redirect:'/app/movie',
    component: () => import('@/views/main/main.vue'),
    children: 
        mainRouter
    
  },
  ...loginRouter,
  ...MineRouter,
  ...MovieRouter,
  {
    path: '/search',
    name: 'search',
    component: () => import('@/views/search/search.vue')
  },
  {
    path: '*',
    redirect: {
      name:'app'
    }
  }
]

const router = new VueRouter({
  routes,
  mode: 'hash', 
  // base: process.env.BASE_URL,
  base: ''
})


const VueRouterPush = Router.prototype.push
Router.prototype.push = function push (to) {
  return VueRouterPush.call(this,to).catch(err=>err)
}
export default router
